#include "actualdatamodel.h"

ActualDataModel::ActualDataModel()
{

}

QTreeWidgetItem*
ActualDataModel::recSearch(QTreeWidgetItem* node,QString& _data, COLSDATA type)
{
    QString this_data = node->text(type);
    if(node->text(TYPE) == BOOKMARKSTR)
    {
        if(_data == this_data)
            return node;
        else
            return 0;
    }
    else
    {
        QTreeWidgetItem* rr = 0;
        for(int i=0;i<node->childCount();i++)
        {
            rr = recSearch(node->child(i), _data, type);
            if(rr)
                return rr;
        }
        return 0;
    }
}

 void
 ActualDataModel::
 inOrderTraversalRec(QTreeWidgetItem* node,QString& _data, COLSDATA type, bool (*func)(QString&, QString&),QList<QTreeWidgetItem*>* list)
 {
     QString this_data = node->text(type);
     qDebug() << node->text(TYPE);
     if(node->text(TYPE) == BOOKMARKSTR)
     {

         if(func(this_data,_data))
         {
            //qDebug()<<node->text(0);
            list->append(node);
            return;
         }
         else
             return;
     }
     else
     {
         for(int i=0;i<node->childCount();i++)
         {
             inOrderTraversalRec(node->child(i), _data, type,func,list);
         }
     }
 }
